﻿using cpe.cpein.SERVER.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace cpe.cpein.SERVER.Tools
{
    public static partial class ObjectConverter
    {
        /// <summary>
        /// Function used to convert a WS RelationType to a Data RelationType.
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static DATA.RelationType RelationTypeConverter(RelationType RelationType)
        {
            if (RelationType == null)
                return null;

            return new DATA.RelationType()
            {
                rlt_id = RelationType.Id,
                rlt_value = RelationType.Value,
                rlt_isdeleted = RelationType.IsDeleted
            };
        }

        /// <summary>
        /// Function used to convert a Data RelationType to a WS RelationType.
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static RelationType RelationTypeConverter(DATA.RelationType RelationType)
        {
            if (RelationType == null)
                return null;

            return new RelationType()
            {
                Id = RelationType.rlt_id,
                Value = RelationType.rlt_value,
                IsDeleted = RelationType.rlt_isdeleted
            };
        }

        /// <summary>
        /// Function used to convert a list of Data RelationTypes to a List of WS RelationTypes.
        /// </summary>
        /// <param name="RelationTypes"></param>
        /// <returns></returns>
        public static List<RelationType> RelationTypeConverter(List<DATA.RelationType> RelationTypes)
        {
            List<RelationType> res = new List<RelationType>();
            foreach (DATA.RelationType us in RelationTypes)
                res.Add(Tools.ObjectConverter.RelationTypeConverter(us));

            return res;
        }

        /// <summary>
        /// Function used to convert a list of WS RelationTypes to a List of Data RelationTypes.
        /// </summary>
        /// <param name="RelationTypes"></param>
        /// <returns></returns>
        public static List<DATA.RelationType> RelationTypeConverter(List<RelationType> RelationTypes)
        {
            List<DATA.RelationType> res = new List<DATA.RelationType>();
            foreach (RelationType us in RelationTypes)
                res.Add(Tools.ObjectConverter.RelationTypeConverter(us));

            return res;
        }
    }
}